<?php 
class GoodsTypeControl extends CommonControl{
    /**
     * 商品列表页
     * @return [type] [description]
     */
    public function index(){
        $db=M('g_goods_type')->all();
        $this->assign('field',$db);
        $this->display();
    }

    /**
     * 添加商品类型
     */
    public function add(){
        if(IS_POST){
            $db=M('g_goods_type');
            $db->add();
            $this->success('添加成功','index',1);
        }else{
            $this->display();
        }
    }

    /**
     * 商品删除
     * @return [type] [description]
     */
    public function del(){
        $gt_id = q("get.gt_id", "intval");
        if ($gt_id) {
            $db = M("g_goods_type");
            $db->del($gt_id); //删除商品类型表
            $this->success("删除商品分类成功", "index", 1);
        }
    }

    /**
     * 商品编辑
     */
    public function edit(){
        if(IS_POST){
            $db = M("g_goods_type");
            $db->save();
            $this->success("修改商品类型成功", "index");
        }else{
            $gt_id = q("get.gt_id", "intval");
            if ($gt_id) {
                $db = M("g_goods_type");
                $field = $db->find($gt_id);
                $this->assign("field", $field);
                $this->display();
            }      
        }    
    }



















}
 ?>